// 对axios的封装
import axios from 'axios'
import deepClone from '@/utils/deepClone'

// let is_baseURL = 'http://localhost:8088/' // 测试环境
// let is_baseURL = 'http://zp.eapjfz.com/' // 线上环境

// axios.defaults.baseURL = is_baseURL
axios.defaults.headers = {
  'Content-Type': 'application/x-www-form-urlencoded'
}



// 创建axios实例
const request = axios.create({
  baseURL:  '/api'
})

// response服务器响应拦截器
request.interceptors.response.use(
  response => {
    const res = response.data
    return res
  },
  error => {
    console.log('err', error)
  }
)

request.interceptors.request.use(function(config) {
  config.params = {
    // ...deepClone(config.params),
    ...config.params = config.params,
    uid: localStorage.getItem('UID')
    // uid: '2'

  }
  return config
}, function(error) {
  // 对请求错误做些什么
  return Promise.reject(error)
})

export default request
